'use strict';

//云函数：更新账单记录
const db = uniCloud.database(); //打开链接
const collection = db.collection('money'); //指定表

exports.main = async (event, context) => {

	let res = null;
	// 当有上传id表示要更新数据
	if (!event._id) {
		return {
			code: 0,
			msg: '请检查传参！'
		};
	}


	res = await collection.doc(event._id).update({
		money: parseFloat(event.money),
		remarks: event.remarks
	});

	if (res) {
		return {
			code: 1,
			msg: '更新成功'
		};
	} else {
		return {
			code: 0,
			msg: '更新失败'
		};
	}



};
